$(document).ready(function() {
	 jQuery("#inputDate").datepicker();
	 jQuery("#inputDate").datepicker( "option", "dateFormat", "dd/mm/yy");
	 document.getElementById('mesReporte')[document.getElementById('mesActual').value].selected = true;
	 var anio = document.getElementById("anioReporte");
	 var anioSeleccionado = document.getElementById("anioActual").value;
	 for (var itemIndex = 0; itemIndex < anio.length; itemIndex++)	{
		 if(anio[itemIndex].value==anioSeleccionado){
			 anio[itemIndex].selected = true; 
		 }
	 }	
		
});

function generarReporteAjax() {
	
	new Ajax.Updater(reporteDiv, '/Dietetica/reportes/generarReporte',
	{
		asynchronous : true,
		evalScripts : true,
		parameters :{ 
			anioReporte: $('anioReporte').value,
			mesReporte: $('mesReporte').value,
			dietetica: $('dietetica.id').value
		}
	});
}

function mostrarComboMes(value){
	if (value=='null'){
		$('mesReporte').selectedIndex = 0;
		$('mesReporte').disabled = true;
	}else{
		$('mesReporte').disabled = false;
	}
}

function cambioRadio(value){
	if (value=='1'){
		$('anioReporte').disabled = false;
		$('mesReporte').disabled = false;
		$('inputDate').disabled = true;
	}else{
		$('anioReporte').disabled = true;
		$('mesReporte').disabled = true;
		$('inputDate').disabled = false;
	}
	mostrarComboMes('null');
}

function cambioCombo(){
	document.getElementById('vendedor.id').disabled = false;
	document.getElementById('dietetica.id').disabled = false;
	document.getElementById('cliente.id').disabled = false;
	
	if (document.getElementById('vendedor.id').value!='null'){
		if (document.getElementById('vendedor.id').selectedIndex != 0){
			document.getElementById('dietetica.id').selectedIndex = 0;
			document.getElementById('dietetica.id').disabled = true;
			document.getElementById('cliente.id').selectedIndex = 0;
			document.getElementById('cliente.id').disabled = true;
		}
	}
	if (document.getElementById('dietetica.id').value!='null'){
		if (document.getElementById('dietetica.id').selectedIndex != 0){
			document.getElementById('vendedor.id').selectedIndex = 0;
			document.getElementById('vendedor.id').disabled = true;
			document.getElementById('cliente.id').selectedIndex = 0;
			document.getElementById('cliente.id').disabled = true;
		}
	}
	if (document.getElementById('cliente.id').value!='null'){
		if (document.getElementById('cliente.id').selectedIndex != 0){
			document.getElementById('vendedor.id').selectedIndex = 0;
			document.getElementById('vendedor.id').disabled = true;
			document.getElementById('dietetica.id').selectedIndex = 0;
			document.getElementById('dietetica.id').disabled = true;
		}
	}
}